package com.guojian.common.utils;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * 获取服务器资源
 * 
 * @author guojian
 *
 */
public class WebUtils {

	/**
	 * 获取服务器根路径
	 * 
	 * @param request
	 * @return
	 */
	public static String getRootPath() {
		return getHttpServletRequest().getServletContext().getRealPath("/");
	}

	public static String getExcelTempPath() {
		return getHttpServletRequest().getServletContext().getRealPath("/WEB-INF/temp_excel");
	}

	public static HttpServletRequest getHttpServletRequest() {
		return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
	}

}
